home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / POV-Ray 3.0.2 / src / MacSource / TE32K / myabout.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-07-21  |  3.2 KB  |  150 lines  |  [TEXT/KAHL]

  1. #pragma segment About
  2.  
  3. #include <Desk.h>
  4. #include <Events.h>
  5. #include <Quickdraw.h>
  6. #include <TextEdit.h>
  7. #include <Windows.h>
  8.  
  9. #define LENGTH    20
  10.  
  11.  
  12.  
  13. DoAboutBox(short doWait)
  14. {
  15. Rect            creditRect, lineRect;
  16. GrafPtr            oldPort;
  17. WindowPtr        creditWPtr;
  18. EventRecord        theEvent;
  19. long            iticks;
  20. char            *line1 = "TE32K Demo";
  21. char            *line2 = "Written by Roy Wood";
  22. char            *line3 = "©1992 Silicon Angst Software";
  23. char            *line4 = "122 Britannia Avenue";
  24. char            *line5 = "London, Ontario, Canada N6H 2J5";
  25. char            *line6 = "(519) 438-3177";
  26. short                length,oldLength,countDown,i;
  27. short                x[LENGTH][2],y[LENGTH][2],vx[2],vy[2];
  28. long            finalTicks;
  29. unsigned long   randSeed;
  30.  
  31.     GetPort(&oldPort);
  32.     
  33.     SetRect(&creditRect, 75,75,425,200);
  34.     creditWPtr = NewWindow(nil, &creditRect, "\p1x", false, dBoxProc, (WindowPtr) -1L, false, 0L);
  35.     SetPort(creditWPtr);
  36.     
  37.     CenterWindow(creditWPtr);
  38.     ShowWindow(creditWPtr);
  39.  
  40. MAIN:
  41.     
  42.     BeginUpdate(creditWPtr);
  43.     EndUpdate(creditWPtr);
  44.     
  45.     creditRect = creditWPtr->portRect;
  46.     SetRect(&lineRect, 100,10,350,25);
  47.     
  48.     BackPat(&qd.black);
  49.     EraseRect(&creditRect);
  50.     
  51.     TextMode(srcXor);
  52.     TextSize(12);
  53.     TextFont(3);
  54.     TextFace(bold);
  55.     TextBox(line1, strlen(line1), &lineRect, teJustCenter);
  56.     OffsetRect(&lineRect, 0 , 20);
  57.     
  58.     TextSize(10);
  59.     TextBox(line2, strlen(line2), &lineRect, teJustCenter);
  60.     
  61.     TextFace(0);
  62.     
  63.     OffsetRect(&lineRect, 0 , 25);
  64.     TextBox(line3, strlen(line3), &lineRect, teJustCenter);
  65.     OffsetRect(&lineRect, 0 , 15);
  66.     TextBox(line4, strlen(line4), &lineRect, teJustCenter);
  67.     OffsetRect(&lineRect, 0 , 15);
  68.     TextBox(line5, strlen(line5), &lineRect, teJustCenter);
  69.     OffsetRect(&lineRect, 0 , 15);
  70.     TextBox(line6, strlen(line6), &lineRect, teJustCenter);
  71.  
  72.     PenNormal();
  73.     PenMode(patXor);
  74.     
  75.     GetDateTime(&randSeed);
  76.     
  77.     x[0][0] = 50;
  78.     x[0][1] = 10;
  79.     y[0][0] = 45;
  80.     y[0][1] = 55;
  81.     
  82.     vx[0] = 2;
  83.     vx[1] = -4;
  84.     vy[0] = 3;
  85.     vy[1] = 1;
  86.     
  87.     countDown = 1;
  88.     length = 1;
  89.     oldLength = 0;
  90.     
  91.     creditRect = creditWPtr->portRect;
  92.     creditRect.right = 100;
  93.     
  94.     MoveTo((short) x[0][0],(short) y[0][0]);
  95.     LineTo((short) x[0][1],(short) y[0][1]);
  96.     
  97.     iticks = TickCount();
  98.     
  99.     do
  100.     {
  101.         for (i=0;i<=1;i++)
  102.         {
  103.             x[length][i] = x[oldLength][i] + vx[i];
  104.             
  105.             if (x[length][i] < creditRect.left + 5)
  106.                 vx[i] = (vx[i] > 0) ? vx[i] : -vx[i];
  107.             else if (x[length][i] > creditRect.right - 5)
  108.                 vx[i] = (vx[i] > 0) ? -vx[i] : vx[i];
  109.             
  110.             y[length][i] = y[oldLength][i] + vy[i];
  111.             
  112.             if (y[length][i] < creditRect.top + 5)
  113.                 vy[i] = (vy[i] > 0) ? vy[i] : -vy[i];
  114.             else if (y[length][i] > creditRect.bottom - 5)
  115.                 vy[i] = (vy[i] > 0) ? -vy[i] : vy[i];
  116.         }
  117.         
  118.         MoveTo((short) x[length][0],(short) y[length][0]);
  119.         LineTo((short) x[length][1],(short) y[length][1]);    
  120.         
  121.         oldLength = length;
  122.         
  123.         if (++length >= LENGTH)
  124.             length = 0;
  125.         
  126.         
  127.         if (countDown)
  128.             countDown = length;
  129.         
  130.         if (!countDown)
  131.         {
  132.             MoveTo((short) x[length][0],(short) y[length][0]);
  133.             LineTo((short) x[length][1],(short) y[length][1]);    
  134.         }
  135.         
  136.         SystemTask();
  137.         GetNextEvent(everyEvent, &theEvent);
  138.         
  139.         Delay(1L,&finalTicks);
  140.         
  141.         if (theEvent.what==updateEvt && theEvent.message==(long) creditWPtr)
  142.             goto MAIN;
  143.         
  144.     }    while ((!doWait && (theEvent.what != mouseDown))||(doWait && (TickCount() < iticks + doWait)));
  145.     
  146.     
  147.     DisposeWindow(creditWPtr);
  148.     
  149.     SetPort(oldPort);
  150. }